home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / gas / debug.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-04  |  2.6 KB  |  105 lines

  1. /* This file is debug.c
  2.    Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3.  
  4.    This file is part of GAS, the GNU Assembler.
  5.  
  6.    GAS is free software; you can redistribute it and/or modify
  7.    it under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2, or (at your option)
  9.    any later version.
  10.  
  11.    GAS is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with GAS; see the file COPYING.  If not, write to
  18.    the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  19.  
  20. /* Routines for debug use only.  */
  21.  
  22. #include "as.h"
  23. #include "subsegs.h"
  24.  
  25. dmp_frags ()
  26. {
  27.   frchainS *chp;
  28.   char *p;
  29.  
  30.   for (chp = frchain_root; chp; chp = chp->frch_next)
  31.     {
  32.       switch (chp->frch_seg)
  33.     {
  34.     case SEG_DATA:
  35.       p = "Data";
  36.       break;
  37.     case SEG_TEXT:
  38.       p = "Text";
  39.       break;
  40.     default:
  41.       p = "???";
  42.       break;
  43.     }
  44.       printf ("\nSEGMENT %s %d\n", p, chp->frch_subseg);
  45.       dmp_frag (chp->frch_root, "\t");
  46.     }
  47. }
  48.  
  49. dmp_frag (fp, indent)
  50.      struct frag *fp;
  51.      char *indent;
  52. {
  53.   for (; fp; fp = fp->fr_next)
  54.     {
  55.       printf ("%sFRAGMENT @ 0x%x\n", indent, fp);
  56.       switch (fp->fr_type)
  57.     {
  58.     case rs_align:
  59.       printf ("%srs_align(%d)\n", indent, fp->fr_offset);
  60.       break;
  61.     case rs_fill:
  62.       printf ("%srs_fill(%d)\n", indent, fp->fr_offset);
  63.       printf ("%s", indent);
  64.       var_chars (fp, fp->fr_var + fp->fr_fix);
  65.       printf ("%s\t repeated %d times,",
  66.           indent, fp->fr_offset);
  67.       printf (" fixed length if # chars == 0)\n");
  68.       break;
  69.     case rs_org:
  70.       printf ("%srs_org(%d+sym @0x%x)\n", indent,
  71.           fp->fr_offset, fp->fr_symbol);
  72.       printf ("%sfill with ", indent);
  73.       var_chars (fp, 1);
  74.       printf ("\n");
  75.       break;
  76.     case rs_machine_dependent:
  77.       printf ("%smachine_dep\n", indent);
  78.       break;
  79.     default:
  80.       printf ("%sunknown type\n", indent);
  81.       break;
  82.     }
  83.       printf ("%saddr=%d(0x%x)\n", indent, fp->fr_address, fp->fr_address);
  84.       printf ("%sfr_fix=%d\n", indent, fp->fr_fix);
  85.       printf ("%sfr_var=%d\n", indent, fp->fr_var);
  86.       printf ("%sfr_offset=%d\n", indent, fp->fr_offset);
  87.       printf ("%schars @ 0x%x\n", indent, fp->fr_literal);
  88.       printf ("\n");
  89.     }
  90. }
  91.  
  92. var_chars (fp, n)
  93.      struct frag *fp;
  94.      int n;
  95. {
  96.   unsigned char *p;
  97.  
  98.   for (p = (unsigned char *) fp->fr_literal; n; n--, p++)
  99.     {
  100.       printf ("%02x ", *p);
  101.     }
  102. }
  103.  
  104. /* end of debug.c */
  105.